<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;

class RegisterController extends Controller
{
	/**
	 * [index description]
	 * @return [type] [description]
	 */
    public function index()
    {
    	return view('register/index');
    }

    /**
     * [register description]
     * @return [type] [description]
     */
    public function register()
    {
    	$this->validate(request(), [
                'name' => 'required|min:3|unique:users',
                'email' => 'required|unique:users|email',
                'password' => 'required|min:5|max:10|confirmed'
            ]);
        $name = request('name');
        $password = bcrypt(request('password'));
        $email = request('email');
        User::create(compact('name', 'password', 'email'));

        return redirect('/login');
    }
}
